import {defineStore} from 'pinia';
import {Setting} from "~/entity/setting";

export const setting = defineStore('setting', {
    state: () => ({
        setting: {
            disableCaptcha: true,
            seoSeparate: "",
            seoDescription: "",
            name: "",
            disableRegister: false,
            seoKeywords: [],
            url: "",
            footerInfo: "",
            homeSiteCount: 16
        } as Setting
    }),
    getters: {},
    actions: {
        setSetting(setting: any) {
            this.setting = setting;
        },
        getSetting() {
            const {settingApi} = useApi();
            settingApi.getSetting().then((res: any) => {
                this.setSetting(res.data);
            });
        }
    },
    persist: true,
})